package com.operation.controller;

import com.operation.beans.LevelDirectory;
import com.operation.beans.Result;
import com.operation.service.LevelDirectoryService;
import com.operation.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class LevelDirectoryServiceController {
    @Autowired
    LevelDirectoryService levelDirectoryService;

    @RequestMapping(value = "/levelDirectories",method = RequestMethod.POST)
    public Result addOneRecord(@RequestBody LevelDirectory levelDirectory){
        return ResultUtil.success(levelDirectoryService.addOneRecord(levelDirectory),0);
    }

    @RequestMapping(value = "/deleteLevelDirectories",method = RequestMethod.POST)
    public Result deleteOneRecord(@RequestBody LevelDirectory levelDirectory){
        return ResultUtil.success(levelDirectoryService.deleteOneRecord(levelDirectory),0);
    }

    @RequestMapping(value = "/levelDirectories",method = RequestMethod.PUT)
    public Result updateOneRecord(@RequestBody LevelDirectory levelDirectory){
        return ResultUtil.success(levelDirectoryService.updateOneRecord(levelDirectory),0);
    }

    @RequestMapping(value = "/levelDirectories/{tType}",method = RequestMethod.GET)
    public Result getOneRecordOfTwoLevel(@PathVariable Integer tType){
        return ResultUtil.success(levelDirectoryService.queryAllTwoLevelRecord(tType),0);
    }

    @RequestMapping(value = "/OneLevelDirectories",method = RequestMethod.GET)
    public Result getOneRecord(){
        return ResultUtil.success(levelDirectoryService.queryAllOneLevelRecord(),0);
    }

    @RequestMapping(value = "/selectOType/{one}",method = RequestMethod.GET)
    public Result getOneRecord(@PathVariable String one){
        return ResultUtil.success(levelDirectoryService.selectOType(one),0);
    }
}
